#!/bin/bash
outputsDir="build/app/outputs"
releaseDir="${outputsDir}/flutter-apk"

buildApk(){
   if [ ! -d "$releaseDir" ]; then
          mkdir "$releaseDir"
      fi
      cd "$releaseDir"
      # rm -rf *
      cd -
    # --build-name=$buildAppVersion 构建版本号  --build-number=$buildAppBuild 构建code
     flutter build apk
    open ${outputsDir}
}

#  执行打包 程序
read -p "选择打包环境(app_evn.dart), android_release: Y >>>>>: " isRelease
echo "打包时间--> $(date +"%Y-%m-%d %H:%M:%S")"
if [[ $isRelease == 'Y' || $isRelease == 'y' ]]
then
  echo "开始打包--> (环境Android_Release)，日志请查看 builder_app.log"
  buildApk "$1" >builder_app.log 2>&1
  echo "打包完成-->$(date +"%Y-%m-%d %H:%M:%S") 打开文件$releaseDir"
  echo "##########################################"
  echo "\n"
else
  echo "\n"
  echo "打包操作中断"
fi